Есть желание использовать современные языковые фитчи, но переписывать код в ручную долго и скучно, тогда можно воспользоваться помощью искусственного интеллекта😄
Для того чтобы сделать свой код более современным используй следующий промпт:
Refactor the following code to modern [Тут напиши стандарт] programming standards:
[Сюда вставь свой код]
❗️Пример использования промпта:
Refactor the following code to modern c++23 programming standards:
int* createIntArray(int size) { int* arr = new int[size]; for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
// Option 1: Return a std::vector (recommended for most cases) auto createIntArray(int size) -> std::vector<int> { std::vector<int> arr(size); std::ranges::generate(arr, [i = 0]() mutable { return i * i++; }); return arr; }
// Option 2: Return a std::unique_ptr (if you specifically need heap allocation) auto createIntArrayUnique(int size) -> std::unique_ptr<int[]> { auto arr = std::make_unique<int[]>(size); for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
Это достаточно простой и быстрый способ привести код к текущему стандарту. К сожалению результат работы промпта всё де придётся проверить, так как текущая реализация AI далека от идеала, но даже так времени можно сэкономить массу.
👀 А как ты приводишь свой код к более современному виду? Делитесь в комментариях!
Есть желание использовать современные языковые фитчи, но переписывать код в ручную долго и скучно, тогда можно воспользоваться помощью искусственного интеллекта😄
Для того чтобы сделать свой код более современным используй следующий промпт:
Refactor the following code to modern [Тут напиши стандарт] programming standards:
[Сюда вставь свой код]
❗️Пример использования промпта:
Refactor the following code to modern c++23 programming standards:
int* createIntArray(int size) { int* arr = new int[size]; for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
// Option 1: Return a std::vector (recommended for most cases) auto createIntArray(int size) -> std::vector<int> { std::vector<int> arr(size); std::ranges::generate(arr, [i = 0]() mutable { return i * i++; }); return arr; }
// Option 2: Return a std::unique_ptr (if you specifically need heap allocation) auto createIntArrayUnique(int size) -> std::unique_ptr<int[]> { auto arr = std::make_unique<int[]>(size); for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
Это достаточно простой и быстрый способ привести код к текущему стандарту. К сожалению результат работы промпта всё де придётся проверить, так как текущая реализация AI далека от идеала, но даже так времени можно сэкономить массу.
👀 А как ты приводишь свой код к более современному виду? Делитесь в комментариях!
Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”
Telegram is riding high, adding tens of million of users this year. Now the bill is coming due.Telegram is one of the few significant social-media challengers to Facebook Inc., FB -1.90% on a trajectory toward one billion users active each month by the end of 2022, up from roughly 550 million today.
Библиотека C C разработчика | cpp boost qt from us